package javase1.day08.demo02;
/*
String中与转换相关的方法：
public char[] toCharArray(){}:将字符串转换为字符数组
public byte[] getBytes(){}:将字符串转换为字节数组
public String replace(CharSequence oldString,CharSequence newString){}
将老字符串替换成新字符串
CharSequence:字符序列，相当于String


 */
public class Demo04StringConvert {
    public static void main(String[] args) {
//        public char[] toCharArray(){}:将字符串转换为字符数组
        String str1="I love java";
        char[] charArray1=str1.toCharArray();
        System.out.println(str1);//I love java
        System.out.println(charArray1);//I love java
        System.out.println(charArray1[3]);//o
        System.out.println("=============");

//        public byte[] getBytes(){}:将字符串转换为字节数组
        String str2="I like to learn java";
        byte[] bytesArray=str2.getBytes();
        System.out.println(bytesArray);//[B@4554617c
        System.out.println("=============");

//        public String replace(CharSequence oldString,CharSequence newString){}
//        将老字符串替换成新字符串
        String str3="I like to play basketball";
        String str4=str3.replace("basketball","football");
        System.out.println(str3);//I like to play basketball
        System.out.println(str4);//I like to play football






    }


}
